package controllers

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/logs"
	"github.com/astaxie/beego/orm"
	"github.com/tidwall/gjson"
)

type mainController struct {
	beego.Controller
	o              orm.Ormer
	controllerName string
	actionName     string
}

func (c *mainController) Prepare() {
	for i, m := range c.Ctx.Request.Header {
		logs.Info("%s:%s", i, m)
	}
	beego.Info(c.Input())
	beego.Info("######QUERY START######")
	beego.Info(c.Ctx.Request.URL.Query())
	beego.Info("######QUERY  END######")

	beego.Info(c.Ctx.Request.Method)

	if c.Ctx.Request.Method != "GET"{
		beego.Info("######BODY START######")
		jsonStr := string(c.Ctx.Input.RequestBody)
		beego.Info("\n")
		beego.Info(jsonStr)
		m, ok := gjson.Parse(jsonStr).Value().(map[string]interface{})
		if ok {
			beego.Info(m)
		}
		beego.Info("######BODY  END######")
	}


	c.o = orm.NewOrm()
}

func (c *mainController) Finish() {
}
